package com.mdd.admin.controller;

import com.mdd.admin.aop.Log;
import com.mdd.admin.esign.exception.EsignDemoException;
import com.mdd.admin.service.FileService;
import com.mdd.admin.validate.GetInformationDTO;
import com.mdd.common.core.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * 合同控制器 基于普通直接上传待签署文件发起签署
 */
@RestController
@RequestMapping("api/file")
@Api(tags = "合同控制器")
public class FileController {

    @Autowired
    private FileService fileService;

    @Log(title = "上传合同")
    @ApiOperation(value = "上传合同")
    @PostMapping("/uploadFile")
    public AjaxResult<Object> uploadFile(MultipartFile file){
        return AjaxResult.success(fileService.uploadFile(file));
    }

    /**
     * 案件合同列表 查看预览合同
     * @param dto
     * @return
     */
    @Log(title = "pc获取合同预览链接")
    @ApiOperation(value = "pc获取合同预览链接")
    @PostMapping("/viewSigningDetails")
    public AjaxResult<Map<String, String>> viewSigningDetails(@RequestBody GetInformationDTO dto) throws EsignDemoException {
        return fileService.viewSigningDetails(dto);
    }

}
